/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Control;

import Entity.Owner;
import Entity.Veterinarian;
import Services.OwnerService;
import Services.VeterinarianService;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author microraptor
 */
public class ControlVeterinarian {
    
    EntityManagerFactory emf;
        EntityManager em;

    public ControlVeterinarian() {
        emf = Persistence.createEntityManagerFactory("HPVAS-2013-1-BPU");
    }
    
    public void createVeterinarian (String name, String lastName, String ssn, Date birthDate, String birthPlace, String focusOfPractice, String spec, int salary, String graduatedAt){
        VeterinarianService vs = new VeterinarianService(emf);
        Veterinarian v = new Veterinarian(name, lastName, ssn, birthDate, birthPlace, focusOfPractice, spec, salary, graduatedAt);
        vs.crear(v);
    }
    
    public void editVeterinarian (Long id, String name, String lastName, String ssn, Date birthDate, String birthPlace, String focusOfPractice, String spec, int salary, String graduatedAt){
    
    }
    
    public void removeVeterinarian (long id){
        VeterinarianService vs = new VeterinarianService(emf);
        try {
            vs.destroy(id);
        }catch(Exception e ){
            
        }
    }
    
    public List<Veterinarian> readAllVeterinarian (){
        VeterinarianService vs = new VeterinarianService(emf);
        return vs.findVeterinarianEntities();
    }
    
    public Veterinarian readVeterianarian(Long id){
        VeterinarianService vs = new VeterinarianService(emf);
        return vs.findVeterinarian(id);
    }

    public void editVeterinarian(Veterinarian veterianarian) throws Exception {
        VeterinarianService vs = new VeterinarianService(emf);
        vs.edit(veterianarian);
    }
}
